package cn.iocoder.yudao.module.crossborder.platform.dal.mysql.platformfeeconfig;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crossborder.platform.dal.dataobject.platformfeeconfig.PlatformFeeConfigDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crossborder.platform.controller.admin.platformfeeconfig.vo.*;

/**
 * 跨境电商平台费率配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PlatformFeeConfigMapper extends BaseMapperX<PlatformFeeConfigDO> {

    default PageResult<PlatformFeeConfigDO> selectPage(PlatformFeeConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlatformFeeConfigDO>()
                .eqIfPresent(PlatformFeeConfigDO::getPlatformId, reqVO.getPlatformId())
                .eqIfPresent(PlatformFeeConfigDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(PlatformFeeConfigDO::getFeeType, reqVO.getFeeType())
                .likeIfPresent(PlatformFeeConfigDO::getFeeName, reqVO.getFeeName())
                .eqIfPresent(PlatformFeeConfigDO::getFeeNameEn, reqVO.getFeeNameEn())
                .eqIfPresent(PlatformFeeConfigDO::getCalculationMethod, reqVO.getCalculationMethod())
                .eqIfPresent(PlatformFeeConfigDO::getFeeRate, reqVO.getFeeRate())
                .eqIfPresent(PlatformFeeConfigDO::getFixedAmount, reqVO.getFixedAmount())
                .eqIfPresent(PlatformFeeConfigDO::getMinFee, reqVO.getMinFee())
                .eqIfPresent(PlatformFeeConfigDO::getMaxFee, reqVO.getMaxFee())
                .eqIfPresent(PlatformFeeConfigDO::getCurrency, reqVO.getCurrency())
                .eqIfPresent(PlatformFeeConfigDO::getCategoryIds, reqVO.getCategoryIds())
                .eqIfPresent(PlatformFeeConfigDO::getProductTypes, reqVO.getProductTypes())
                .eqIfPresent(PlatformFeeConfigDO::getTierConfig, reqVO.getTierConfig())
                .betweenIfPresent(PlatformFeeConfigDO::getEffectiveDate, reqVO.getEffectiveDate())
                .betweenIfPresent(PlatformFeeConfigDO::getExpireDate, reqVO.getExpireDate())
                .eqIfPresent(PlatformFeeConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PlatformFeeConfigDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(PlatformFeeConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PlatformFeeConfigDO::getId));
    }

    /**
     * 根据平台ID查询费率配置列表
     *
     * @param platformId 平台ID
     * @return 费率配置列表
     */
    default List<PlatformFeeConfigDO> selectListByPlatformId(Long platformId) {
        return selectList(new LambdaQueryWrapperX<PlatformFeeConfigDO>()
                .eq(PlatformFeeConfigDO::getPlatformId, platformId)
                .orderByAsc(PlatformFeeConfigDO::getFeeType));
    }

}